package com.coocaa.internship.dao.provider;

import com.coocaa.internship.pojo.Company;
import org.springframework.util.StringUtils;

/**
 * @Description: CompanySqlProvider
 * @Author: zwh
 * @Date: 2019-07-25
 * @Time: 20:17
 */
public class CompanySqlProvider {
    String TABLE_NAME = "company";

    public String updateCompanyById(Company company) {
        StringBuilder sql = new StringBuilder("update " + TABLE_NAME + " set ");
        if (!StringUtils.isEmpty(company.getCompanyLogo())) {
            sql.append("company_logo=#{companyLogo} ,");
        }
        if (!StringUtils.isEmpty(company.getCompanyName())) {
            sql.append("company_name=#{companyName} ,");
        }
        if (!StringUtils.isEmpty(company.getCompanyScale())) {
            sql.append("company_scale=#{companyScale} ,");
        }
        if (!StringUtils.isEmpty(company.getCompanyType())) {
            sql.append("company_type=#{companyType} ,");
        }
        sql.replace(sql.length() - 1, sql.length(), "");
        return sql.append(" where company_id=#{companyId}").toString();
    }
}
